package com.zxl.test;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

/**
 * @author ken
 * @docRoot 加密算法(目前支持SHA1、MD5)
 * @version 2006.5.25
 */

public class Pb_M_EncryptTransformer {
	
	public static void main(String args[]) {
		System.out.println("123456:" + SHA1("123456"));
	}
	
	
	public static String SHA1(String ps_Source) {
		MessageDigest alga = null;
		try {
			alga = java.security.MessageDigest.getInstance("SHA-1");
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		alga.update(ps_Source.getBytes());
		BASE64Encoder B64 = new BASE64Encoder();
		return B64.encode(alga.digest());
	}
	public static String initialization(){
		return SHA1("123456");
	}
}